/** 网页 v1.0.0 **/
var kaHtml = {
    dropdownMap: new Map(),//顶部菜单事假Map
    type2ButtonMap: new Map(),//类型2 分割按钮Map
    type3ButtonMap: new Map(),//类型3 时钟Map
    type4ButtonMap: new Map(),//类型4 时钟Map
    type5ButtonMap: new Map(),//类型5 按钮
    type6ButtonMap: new Map(),//类型6 新闻
    type7ButtonMap: new Map(),//类型7 用户/租户/公司banner
    type8ButtonMap: new Map(),//类型8 上下文滚动
    type9ButtonMap: new Map(),//类型9 广告栏
    type10ButtonMap: new Map(),//类型10 tab页面
    type12ButtonMap: new Map(),//类型12 用户
    type13ButtonMap: new Map(),//类型12 用户
    init: function (divId, json, num, callback) {//初始化
        kaHtmlLoadEvent.delete();
        var divHtml = kaHtml.load(json, num, divId);
        $("#" + divId).html(divHtml);
        //加载水印
        ka.watermark('.layui-card');
        kaHtmlLoadEvent.head.top(divId); //加载顶部内容
        kaHtmlLoadEvent.body.type2(divId);//加载类型2 分割按钮事件
        kaHtmlLoadEvent.body.type3(divId);//加载类型3 时钟Map
        kaHtmlLoadEvent.body.type4(divId);//加载类型4 时钟Map
        kaHtmlLoadEvent.body.type5(divId);//加载类型5 按钮标签
        kaHtmlLoadEvent.body.type6(divId);//加载类型6 新闻
        kaHtmlLoadEvent.body.type7(divId);//加载类型7 用户/租户/公司banner
        kaHtmlLoadEvent.body.type8(divId);//加载类型8 上下文滚动
        kaHtmlLoadEvent.body.type9(divId);//加载类型9 广告栏
        kaHtmlLoadEvent.body.type10(divId);//加载类型10 tab页面
        //结束加载执行
        if (callback != undefined && callback != null && callback != "") {
            callback();
        }
    },
    getjon: function (json) { //获取JSON
        var defaultJson = {};
        //ID
        if(json.id != undefined && json.id != null && json.id != ""){ 
            defaultJson["id"] = json.id;
        } else {
            defaultJson["id"] = ka.uuidStr();
        }
        //分割多大 
        if(json.number != undefined && json.number != null && json.number != ""){
            defaultJson["number"] = json.number;
        } else {
            defaultJson["number"] = 12;
        }
        //子项
        if(json.child != undefined && json.child != null && json.child != "" && json.child.length > 0){
            defaultJson["child"] = json.child;
        }
        //Html 类型
        if(json.type != undefined && json.type != null && json.type != ""){
            defaultJson["type"] = json.type;
        } else {
            defaultJson["type"] = 1;
        }
        //标题
        if(json.title != undefined && json.title != null && json.title != ""){
            defaultJson["title"] = json.title;
        }
        //内容
        if(json.body != undefined && json.body != null && json.body != ""){
            defaultJson["body"] = json.body;
        }
        //css top位置
        if(json.clsTop != undefined && json.clsTop != null && json.clsTop != ""){
            defaultJson["clsTop"] = json.clsTop;
        }
        //css left位置
        if(json.clsLeft != undefined && json.clsLeft != null && json.clsLeft != ""){
            defaultJson["clsLeft"] = json.clsLeft;
        }
        //css 高度
        if(json.height != undefined && json.height != null && json.height != ""){
            defaultJson["height"] = json.height;
        }
        //css 
        if(json.md != undefined && json.md != null && json.md != "" && json.md.length > 0){
            defaultJson["md"] = json.md;
        }
        return defaultJson;
    },
    load: function (json, num, divId) {//加载html
        var currNum = 0;
        var html = `<div class="layui-row">`;
        for (var i in json) {
            var key = json[i]["number"];
            var child = json[i]["child"];
            var clsTop = json[i]["clsTop"];
            var clsLeft = json[i]["clsLeft"];
            var clsRight = json[i]["clsRight"];
            var clsBottom = json[i]["clsBottom"];
            html = html + `<div class="layui-col-xs12 layui-col-md` + key + ` col-xl" style="`
                + (clsLeft != undefined && clsLeft != null ? ("padding-left:" + clsLeft + ";") : "")
                + (clsRight != undefined && clsRight != null ? ("padding-right:" + clsRight + ";") : "")
                + (clsBottom != undefined && clsBottom != null ? ("padding-bottom:" + clsBottom + ";") : "")
                + (clsTop != undefined && clsTop != null ? ("padding-top:" + clsTop + ";") : "") + `">`;
            if (child != undefined && child != null && child != "" && child.length > 0) { //加载布局
                html = html + kaHtml.load(child, num + 1, divId);
            } else { //加载面板
                var type = json[i]["type"];
                if (type != undefined && type != null && type != "") {
                    html = html + kaHtml.typeHtml[type](json[i], divId);
                }
            }
            html = html + `</div>`;
            currNum++;
        }
        html = html + `</div>`;
        return html;
    },
    typeHtml: {
        "1": function (json, divId) {// 面板 自定义HTML
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
            <div class="layui-card" style="` + heightStr + minHeightStr + `">
                `+ title + `
                <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                    `;
            if (body != undefined && body != null && body != "") {
                html = html + body;
            }
            html = html + `
                </div>
            </div>
            `;
            return html;
        },
        "2": function (json, divId) {// 面板 标签 横向选项卡
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            var bodyHtml = kaHtmlLoadContent.body.type2(body, divId);
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        ` ;
            if (body != undefined && body != null && body.length > 0) {
                html = html + bodyHtml;
            }
            html = html + `
                </div>
            </div>
            `;
            return html;
        },
        "3": function (json, divId) {// 面板 时钟
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
            <div class="layui-card" style="` + heightStr + minHeightStr + `">
                <div class="layui-card-body type3layui-card-body">`;
            if (body != undefined && body != null && body != "") {
                var bodyId = body.id;
                html = html + `
                        <img class="type3layui-card-body-img" src="static/images/1.svg" />
                        <div class="" style="float:left;width:100%;height: 35px;line-height: 35px;font-size: 15px;">
                            <a href="javascript:;" class="layui-font-blue" id="` + bodyId + `_gzzt_select">
                                <span style="margin-right: 5px;">💻</span><span id="` + bodyId + `_gzzt" style="color: #0066ff !important;">未登录</span>
                                <i class="layui-icon layui-font-12 layui-icon-down"></i>
                            </a>
                        </div>
                        <div style="float:left;">
                            <button id="` + bodyId + `_qd" type="button" class="layui-btn layui-bg-blue" style="height: 90px;width: 90px;background: linear-gradient(321deg, #0066ff 0, #0066ff00 80%);border: 0px;border-radius: 3px;font-size: 25px;">
                                签到
                            </button>
                        </div>
                        <div style="float:left;margin-left: 10px;">
                           <div style="height: 50px;padding-bottom: 6px;">
                                <div style="font-size: 16px;color: dimgray;line-height: 17px;cursor: pointer;" onclick="kaOtherEvent.lookSigninList('` + bodyId + `')">已经签到<span id="` + bodyId + `_qd_day" style="color: red;margin-left: 3px;margin-right: 3px;">0</span>天</div>
                                <div id="` + bodyId + `_week" style="height: 35px;line-height: 35px;font-size: 24px;background: linear-gradient(to right, #ff8f00, #0066ff, #070c03);-webkit-background-clip: text;-webkit-text-fill-color: transparent;"></div>
                            </div>
                            <div id="` + bodyId + `_sz">
                            </div>
                        </div>`;

                kaHtml.type3ButtonMap.set(divId, bodyId);
            }
            html = html + ` </div>
            </div>
            `;
            return html;
        },
        "4": function (json, divId) {// 
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 36px);`) + ` ;padding-top: 0px;">`;
            var bodyHtml = kaHtmlLoadContent.body.type4(body, divId);
            if (body != undefined && body != null && body != "") {

                html = html + bodyHtml;
                kaHtml.type4ButtonMap.set(divId, body);
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "5": function (json, divId) {//类型5 按钮
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        ` ;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type5(body, divId);
                html = html + bodyHtml;
                kaHtml.type5ButtonMap.set(divId, body);
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "6": function (json, divId) {// /类型6 新闻
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        `;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type6(body, divId);
                html = html + bodyHtml;
                kaHtml.type6ButtonMap.set(divId, body);
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "7": function (json, divId) {//类型7 用户/租户/公司banner
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        ` ;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type7(body, divId);
                html = html + bodyHtml;
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "8": function (json, divId) {//类型8 上下文滚动
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        ` ;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type8(body, divId);
                html = html + bodyHtml;
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "9": function (json, divId) {//类型9 广告栏
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        `;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type9(body, divId);
                html = html + bodyHtml;
            }
            html = html + `
                </div>
            </div>
            `;
            return html;
        },
        "10": function (json, divId) {
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        `;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type10(body, divId);
                html = html + bodyHtml;
                kaHtml.type10ButtonMap.set(divId, body);
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        },
        "12": function (json, divId) {
            var html = "";
            var body = json["body"];
            var height = json["height"];
            var minHeight = json["minHeight"];
            var title = kaHtmlLoadContent.head.top(json, divId);
            var minHeightStr = ``;
            var heightStr = ``;
            if (height != undefined && height != null && height != "") {
                heightStr = "height:" + height + ";";
            }
            if (minHeight != undefined && minHeight != null && minHeight != "") {
                minHeightStr = "min-height:" + minHeight + ";";
            }
            html = html + `
                <div class="layui-card" style="` + heightStr + minHeightStr + `">
                    `+ title + `
                    <div class="layui-card-body" style="height: ` + (title == undefined || title == null || title == "" ? `100%;` : `calc(100% - 35px);`) + `">
                        `;
            if (body != undefined && body != null && body != "") {
                var bodyHtml = kaHtmlLoadContent.body.type12(body, divId);
                html = html + bodyHtml;
                kaHtml.type12ButtonMap.set(divId, body);
            }
            html = html + `
                    </div>
                </div>
                `;
            return html;
        }
    },
    kalLayer: function (type,id) {
        var url = "";
        if(type == 1){
            url = "newsdetails.html?id=" + id
        } else {
            url = "newsList0.html"
        }
        var configure = {
            katype: 1,
            content: url
        };
        ka.kalLayerVer(configure);
    }
}
//加载Html内容
var kaHtmlLoadContent = {
    head: {
        top: function (json, divId) {//加载顶部内容
            var title = json["title"];
            var typeHtmlId = json["id"];
            if (title != undefined && title != null && title != "") {
                var mousedownButton = json["md"];
                var mousedownButtonHtml = ``;
                if (mousedownButton != undefined && mousedownButton != null && mousedownButton.length > 0) {
                    var dropdownId = typeHtmlId + "_dropdown";
                    mousedownButtonHtml = `<span style="float: right;"><i class="layui-icon layui-icon-more kacatri2" id="` + dropdownId + `" lay-options="{trigger: 'mousedown'}"></i></span>`;
                    var dmArray = kaHtml.dropdownMap.get(divId);
                    if (dmArray == undefined || dmArray == null || dmArray.length > 0) {
                        dmArray = [];
                    }
                    var dm = {
                        "id": dropdownId,
                        "mbs": mousedownButton
                    };
                    dmArray.push(dm);
                    kaHtml.dropdownMap.set(divId, dmArray);
                }
                title = `<div class="layui-card-header"><i class="icon iconfont icon-diagnose kacatri"></i>` + title
                    + mousedownButtonHtml
                    + `</div>`;

            } else {
                title = "";
            }
            return title;
        }
    },
    body: {
        type2: function (body, divId) {//加载分割按钮事件
            var bodyHtml = `<div class="layui-btn-container">`;
            var mpx = new Map();
            for (var j in body) {
                var stratNumber = mpx.size;
                var randomNumber = Math.floor(Math.random() * 10);
                mpx.set(randomNumber, randomNumber);
                var endNumber = mpx.size;
                if (stratNumber == endNumber) {
                    while (true) {
                        var oldRandomNumber = Math.floor(Math.random() * 10);
                        if (randomNumber != oldRandomNumber) {
                            randomNumber = oldRandomNumber;
                            break;
                        }
                    }
                }
                bodyHtml = bodyHtml
                    + `<button id="` + body[j].id + `"  menu-open-type="` + body[j].menuOpenType + `" menu-type="` + body[j].menuType + `" menu-url="` + body[j].menuUrl + `" menu-id="` + body[j].menuId + `" menu-title="` + body[j].menuTitle + `" type="button" class="layui-btn layui-btn-primary layui-border-blue kabuttonType2">`
                    + `<div class="kabuttonType2Div kabuttonType2DivBG` + randomNumber + `"><i class="` + body[j].icon + ` kabuttonType2DivI"></i></div>`
                    + `<div class="kabuttonType2DivTitle">` + body[j].title + `</div>`
                    + `</button> `;
                var tbArray = kaHtml.type2ButtonMap.get(divId);
                if (tbArray == undefined || tbArray == null || tbArray.length == 0) {
                    tbArray = [];
                }
                tbArray.push(body[j]);
                if (kaHtml.type2ButtonMap != undefined && kaHtml.type2ButtonMap != null) {
                    kaHtml.type2ButtonMap.set(divId, tbArray);
                } else {
                    kaHtml.type2ButtonMap = new Map();
                    kaHtml.type2ButtonMap.set(divId, tbArray);
                }
            }
            bodyHtml = bodyHtml + `</div>`;
            return bodyHtml;
        },
        type4: function (body, divId) {
            var bodyHtml = kagrid.getHtml(body);
            if (kaHtml.type4ButtonMap != undefined && kaHtml.type4ButtonMap != null) {
                kaHtml.type4ButtonMap.set(divId, body);
            } else {
                kaHtml.type4ButtonMap = new Map();
                kaHtml.type4ButtonMap.set(divId, body);
            }
            return bodyHtml;
        },
        type5: function (body, divId) {
            var bodyHtml = `<div class="layui-btn-container">`;
            for (var j in body) {
                bodyHtml = bodyHtml
                    + `<button id="menuType5` + body[j].id + `" menu-open-type="` + body[j].menu.openType + `" menu-type="` + body[j].menu.menuType + `" menu-url="` + body[j].menu.path + `" menu-id="` + body[j].menu.menuId + `" menu-title="` + body[j].menu.menuName + `" style="font-size: 12px;margin-right: 2px;margin-bottom: 5px;height: 28px;line-height: 28px;border-color: #afafaf !important;" type="button" class="layui-btn layui-btn-sm layui-btn-primary">`
                    + `<i style="font-size: 11px;" class="` + body[j].icon + `"></i> <span>` + (body[j].title != undefined && body[j].title != null && body[j].title != "" ? body[j].title : (body[j].name != undefined && body[j].name != null && body[j].name != "") ? body[j].name : body[j].menuName) + `</span><span style="margin-left: 15px;color: #a9a9a9;">( ` + body[j].clickCount + ` )</span>`
                    + `</button>`;
                var tbArray = kaHtml.type5ButtonMap.get(divId);
                if (tbArray == undefined || tbArray == null || tbArray.length == 0) {
                    tbArray = [];
                }
                tbArray.push(body[j]);
                if (kaHtml.type5ButtonMap != undefined && kaHtml.type5ButtonMap != null) {
                    kaHtml.type5ButtonMap.set(divId, tbArray);
                } else {
                    kaHtml.type5ButtonMap = new Map();
                    kaHtml.type5ButtonMap.set(divId, tbArray);
                }
            }
            bodyHtml = bodyHtml + `</div>`;
            return bodyHtml;
        },
        type6: function (body, divId) {
            var bodyHtml = ``;
            if (body != undefined && body != null && body != "") {
                var types = body.types;
                var datas = body.datas;
                var typesHtml = ``;
                var datasHtml = ``;
                for (var i in types) {
                    typesHtml = typesHtml + `<li class="` + (i == 0 ? "layui-this" : "") + `">` + types[i].name + `</li>`;
                    var datasSonHtml = `
                    <div class="layui-tabs-item ` + (i == 0 ? "layui-show" : "") + `">
                        <div id="` + types[i].id + `" class="layui-collapse" lay-accordion>
                            <div id="ncadDivMain` + i + `" class="ncadDivMain">
                                <div class="ncadDivMainDiv">
                                    <div id="ncadDiv` + i + `" class="ncadDiv"></div>
                                    <span class="ncadDivSpan">广告</span>
                                </div>
                            </div>
                    `;
                    var number = 0;
                    for (var j in datas) {
                        if (datas[j].type == types[i].id) {
                            var createTime = layui.util.timeAgo(new Date(datas[j].createTime).getTime());
                            datasSonHtml = datasSonHtml + `
                                <div class="layui-colla-item">
                                    <div class="layui-colla-title"><a href="javascript:void(0);" onclick="kaHtml.kalLayer(1,'` + datas[j].id + `');">` + datas[j].name + `</a><span style="float: right;color: #a3c8ff;">` +  createTime + `</span></div>
                                    <div class="layui-colla-content ` + (number == 0 ? "layui-show" : "") + `">
                                        <img onclick="ka.imgOpenView(this)" alt="` + datas[j].name + `" src="` + datas[j].img + `" style="width: 75px;height: 100%;border: 5px solid #fff;border-radius: 3px;float: left;margin-right: 10px;box-shadow: 0 1px 4px rgba(0, 0, 0, .1);">
                                        <a onclick="kaHtml.kalLayer(1,'` + datas[j].id + `');" style="width: 100%;word-wrap: break-word;">` + datas[j].synopsis + `</a>
                                        <div style="width:100%;text-align: right;margin-top: 20px;"><a href="javascript:void(0);" onclick="kaHtml.kalLayer(1,'` + datas[j].id + `');">查看详情</a></div>
                                    </div>
                                </div>
                            `
                            var tbArray = kaHtml.type6ButtonMap.get(divId);
                            if (tbArray == undefined || tbArray == null || tbArray.length == 0) {
                                tbArray = [];
                            }
                            tbArray.push(datas);
                            if (kaHtml.type6ButtonMap != undefined && kaHtml.type6ButtonMap != null) {
                                kaHtml.type6ButtonMap.set(divId, tbArray);
                            } else {
                                kaHtml.type6ButtonMap = new Map();
                                kaHtml.type6ButtonMap.set(divId, tbArray);
                            }
                            number++;
                        }
                    }
                    datasSonHtml = datasSonHtml + ` 
                         <div style="text-align: right;position: absolute;right: 15px;bottom: 0;"><a href="javascript:void(0);" onclick="kaHtml.kalLayer(1,'');" style="font-size: 12px;display: flex;">更多<i class="icon iconfont icon-angle-double-right" style="font-size: 9px;margin-left: 5px;"></i></a></div></div></div>`
                    datasHtml = datasHtml + datasSonHtml;
                }
            }
            bodyHtml = `
                <div class="layui-tabs layui-tabs-card ka-new-tab" style="height: 100%;box-shadow: 0 0px 0px 0 rgba(0, 0, 0, .1);border-width: 0px;" lay-options="{index: 0}">
                    <ul class="layui-tabs-header">
                        ` + typesHtml + `
                    </ul>
                    <div class="layui-tabs-body">
                         ` + datasHtml + `
                    </div>
                </div>
            `;
            return bodyHtml;
        },
        type7: function (body, divId) {
            var type = body.type;
            if (type == 1) {//获取用户
                var imgBanner = "";
                var avatar = "";
                var buttons = [
                    `
                    <button type="button" class="layui-btn layui-bg-blue layui-btn-sm">
                        <i style="font-size: 11px;" class="icon iconfont icon-paperclip"></i> 查看资料
                    </button>
                    `,
                    `
                    <button type="button" class="layui-btn layui-bg-blue layui-btn-sm">
                        <i style="font-size: 11px;" class="icon iconfont icon-IM"></i> 留言
                    </button>
                    `,
                    `
                    <button type="button" class="layui-btn layui-bg-blue layui-btn-sm">
                        <i style="font-size: 11px;" class="icon iconfont icon-rizhiguanli1"></i> 申请好友
                    </button>
                    `
                ];
                var headTitleStr = ``;
                var buttonsStr = ``;
                var reuseridStr = ``;
                var olduseridStr = ``;
                var userid = body.userid;
                var option = kaValue.getUrl("commonBusGetInfo");
                if (userid != undefined && userid != null && userid != "") {
                    option.url = option.url + "?userid=" + userid;
                }
                option.async = false;
                option.success = function (re) {
                    if (re.code == 200) {
                        var user = re.user;
                        reuseridStr = re.userid;
                        olduseridStr = user.userId;
                        imgBanner = user.banners != undefined && user.banners != null && user.banners != "" ? kaValue.ctx() + user.banners : "admin/images/banner.png";
                        avatar = user.avatar != undefined && user.avatar != null && user.avatar != "" ? kaValue.ctx() + user.avatar : "admin/images/ka.png";
                        if (reuseridStr == undefined || reuseridStr == null || reuseridStr == "") {
                            buttonsStr = ``;
                        } else {
                            buttonsStr = buttons[0] + buttons[1] + buttons[2]
                        }
                        headTitleStr = `
                            <div style="float: left;padding-top: 5px;padding-left: 8px;padding-right: 8px;font-size: 16px;font-weight: bold;height: 100%;line-height: 23px;border-right: 1px dashed #e9e9e9;">
                                <span style="color:#0066ff;">` + user.nickName + `</span>
                                <div style="font-size: 12px;font-weight: 100;color: #828690;">NAME / 名称</div>
                            </div>
                            <div style="float: left;padding-top: 5px;padding-left: 8px;padding-right: 8px;font-size: 16px;font-weight: bold;height: 100%;line-height: 23px;border-right: 1px dashed #e9e9e9;">
                                <span style="color:#464a53;">` + user.email + `</span>
                                <div style="font-size: 12px;font-weight: 100;color: #828690;">Email / 邮箱</div>
                            </div>
                            <div style="float: left;padding-top: 5px;padding-left: 8px;padding-right: 8px;font-size: 16px;font-weight: bold;height: 100%;line-height: 23px;border-right: 1px dashed #e9e9e9;">
                                <span style="color:#464a53;">` + user.phonenumber + `</span>
                                <div style="font-size: 12px;font-weight: 100;color: #828690;">Mobile Number / 手机号码</div>
                            </div>
                        `;
                    }
                }
                ka.ajax(option);
            }
            var html = `
                <img src="`+ imgBanner + `" style="width: 99%;height: 195px;margin-left: 0.5%;border-radius: 5px;border: 2px solid #f5f5f5;"/>
                <img src="`+ avatar + `" style="width:80px;height:80px" class="img-fluid rounded-circle" alt="">
                <div style="height: 45px;">
                    ` + headTitleStr + `
                    <div style="float: right;padding-right: 20px;height: 100%;line-height: 50px;">
                        ` + buttonsStr + `
                    </div>
                </div> `;
            return html;
        },
        type8: function (body, divId) {
            var html = `<div class="scrollbox" id="` + body.id + `_scrollbox"></div>`;
            if (kaHtml.type8ButtonMap != undefined && kaHtml.type8ButtonMap != null) {
                kaHtml.type8ButtonMap.set(divId, body);
            } else {
                kaHtml.type8ButtonMap = new Map();
                kaHtml.type8ButtonMap.set(divId, body);
            }
            return html;
        },
        type9: function (body, divId) {
            var option = kaValue.getUrl("getAdType9");
            option.success = function (re) {
                if (re.code == 200) {
                    NCPDDatas = re.msg;
                } else {
                    kaMsg.error(re);
                }
            }
            ka.ajax(option);
            var html = `<img src="` + NCPDDatas + `" style="width: 100%;height: 100%;border-radius: 5px;">`;
            if (kaHtml.type9ButtonMap != undefined && kaHtml.type9ButtonMap != null) {
                kaHtml.type9ButtonMap.set(divId, body);
            } else {
                kaHtml.type9ButtonMap = new Map();
                kaHtml.type9ButtonMap.set(divId, body);
            }
            return html;
        },
        type10: function (body, divId) {
            var bodyHtml = ``;
            if (body != undefined && body != null && body != "") {
                var typesHtml = ``;
                var datasHtml = ``;
                for (var i in body) {
                    typesHtml = typesHtml + `
                        <li class="` + (i == 0 ? "layui-this" : "") + `">` + body[i].title + `</li>
                    `;
                    datasHtml = datasHtml + `
                        <div id="` + body[i].id + `_content" class="layui-tabs-item ` + (i == 0 ? "layui-show" : "") + `">
                        </div>
                    `;
                }
            }
            bodyHtml = `
                <div class="layui-tabs layui-tabs-card ka-new-tab" style="height: 100%;box-shadow: 0 0px 0px 0 rgba(0, 0, 0, .1);border-width: 0px;">
                    <ul class="layui-tabs-header">
                        ` + typesHtml + `
                    </ul>
                    <div class="layui-tabs-body">
                        ` + datasHtml + `
                    </div>
                </div>
            `;
            return bodyHtml;
        },
        type11: function (body, divId) {
            var bodyHtml = `<div id="` + divId + `" class="layui-row">`;
            if (body != undefined && body != null && body != "") {
                var num = body.num;
                var data = body.data;
                var editBoolean = false;
                if (num == 1) {
                    for (var j in data) {
                        bodyHtml = bodyHtml + `<div class="layui-col-xs1 ka-table-title">` + data[j].name + `</div>`;
                        if (data[j].edit) {
                            bodyHtml = bodyHtml +
                                `<div formId="` + data[j].code + `" class="layui-col-xs11 ka-table-value1" style="border: 0px solid #f0f0f0;">
                                <input type="text" placeholder="带任意前置和后置内容" class="layui-input">
                            </div>`
                                ;
                            if (!editBoolean) {
                                editBoolean = true;
                            }
                        } else {
                            bodyHtml = bodyHtml + `<div formId="` + data[j].code + `" class="layui-col-xs11 ka-table-value1">` + (data[j].value != undefined ? data[j].value : "") + `</div>`;
                        }
                    }
                } else if (num == 2) {
                    for (var j in data) {
                        bodyHtml = bodyHtml + `<div class="layui-col-xs1 ka-table-title">` + data[j].name + `</div>`;
                        if (data[j].edit) {
                            bodyHtml = bodyHtml +
                                `<div formId="` + data[j].code + `" class="layui-col-xs5 ka-table-value2" style="border: 0px solid #f0f0f0;">
                                <input type="text" placeholder="带任意前置和后置内容" class="layui-input">
                            </div>`;
                            if (!editBoolean) {
                                editBoolean = true;
                            }
                        } else {
                            bodyHtml = bodyHtml + `<div formId="` + data[j].code + `" class="layui-col-xs5 ka-table-value2">` + (data[j].value != undefined ? data[j].value : "") + `</div>`;
                        }

                    }
                } else if (num == 3) {
                    for (var j in data) {
                        bodyHtml = bodyHtml + `<div class="layui-col-xs1 ka-table-title">` + data[j].name + `</div>`;
                        if (data[j].edit) {
                            bodyHtml = bodyHtml +
                                `<div formId="` + data[j].code + `" class="layui-col-xs3 ka-table-value3" style="border: 0px solid #f0f0f0;">
                                <input type="text" placeholder="带任意前置和后置内容" class="layui-input">
                            </div>`
                                ;
                            if (!editBoolean) {
                                editBoolean = true;
                            }
                        } else {
                            bodyHtml = bodyHtml + `<div formId="` + data[j].code + `" class="layui-col-xs3 ka-table-value3">` + (data[j].value != undefined ? data[j].value : "") + `</div>`;
                        }
                    }
                }
            }
            bodyHtml = bodyHtml + `</div>`;
            if (editBoolean) {
                bodyHtml = bodyHtml + `
                    <div style="width: 100%;margin-top: 20px;text-align: center;">
                        <button type="button" class="layui-btn layui-bg-blue layui-btn-sm">
                            <i class="icon iconfont icon-duigou" style="font-size: 12px;margin-right: 5px;"></i> 确定
                        </button>
                    </div>
                `;
            }
            return bodyHtml;
        },
        type12: function (body, divId) {
            var bodyHtml = `<div id="` + divId + `" class="layui-row">`;
            if (body != undefined && body != null && body != "") {
                var data = body.data;
                var type = body.type;
                if (type == 1) {//获取用户
                    var imgBanner = "";
                    var avatar = "";
                    var userid = body.userid;
                    var option = kaValue.getUrl("commonBusGetInfo");
                    if (userid != undefined && userid != null && userid != "") {
                        option.url = option.url + "?userid=" + userid;
                    }
                    option.async = false;
                    option.success = function (re) {
                        var user = re.user;
                        reuseridStr = re.userid;
                        olduseridStr = user.userId;
                        imgBanner = user.banners != undefined && user.banners != null && user.banners != "" ? kaValue.ctx() + user.banners : "admin/images/banner.png";
                        avatar = user.avatar != undefined && user.avatar != null && user.avatar != "" ? kaValue.ctx() + user.avatar : "admin/images/ka.png";
                    }
                    ka.ajax(option);
                    var uuid = ka.uuidStr();
                    var userInfor = kaOtherEvent.getUserInfor();
                    var roles = userInfor.roles;
                    var tenant = userInfor.tenant;
                    var rolesHtml = ``;
                    for (var i in roles) {
                        rolesHtml = rolesHtml + `<span class="layui-badge layui-bg-blue">` + roles[i] + `</span>`;
                    }
                    var posts = userInfor.posts;
                    var postsHtml = ``;
                    for (var i in posts) {
                        postsHtml = postsHtml + `<span class="layui-badge layui-bg-blue">` + posts[i].postName + `</span>`;
                    }
                    var tenantHtml = `<span class="layui-badge layui-bg-blue">` + tenant.name + `</span>`;
                    bodyHtml = bodyHtml
                        + `<div onclick="kaOtherEvent.userBannerEdit('` + uuid + `Banner')" class="layui-col-xs12" style="border: 4px double #f5f5f5;padding-top: 5px;padding-bottom: 5px;text-align: center;">`
                        + `<img id="` + uuid + `Banner" src="` + imgBanner + `" style="width: 90%;height: 90px;margin-left: 0.5%;border-radius: 5px;"/>`
                        + `</div>`
                        + `<img id="` + uuid + `Avatar" onclick="kaOtherEvent.userAvatarEdit('` + uuid + `Avatar')" src="` + avatar + `" style="width: 60px;height: 60px;margin-left: 15px;" class="img-fluid rounded-circle" alt="">`
                        + `<div class="layui-col-xs12" style="border-bottom: 1px dashed #e9e9e9;margin-bottom: 10px;padding-bottom: 10px;margin-top: 5px;">`
                        + `
                            <div id="ka_userid" style="text-align: right;padding-right: 5px;width: 200px;float: right;margin-top: -24px;color: #0066ff;font-size: 16px;font-weight: bolder;">` + userInfor.user.userName + `</div>
                            <div class="layui-row">
                                <div class="layui-col-xs1 ka-table-title">手 机</div>
                                <div id="ka_account" class="layui-col-xs10 ka-table-value1" style="width: calc(100% - 180px);">` + userInfor.user.phonenumber + `</div>
                                <div class="layui-col-xs1" style="width: 50px;margin-top: 5px;margin-right: 5px;height: 36px;line-height: 45px;text-align: center;font-size: 12px;">
                                    <a href="javascript:void(0);" onclick="kaOtherEvent.updateUserMobilePhone('` + userInfor.user.id + `','` + userInfor.user.phonenumber + `');"><i class="layui-icon layui-icon-edit" style="font-size: 12px;font-weight: 900;"></i> 修改</a>
                                </div>
                            </div>
                            <div class="layui-row">
                                <div class="layui-col-xs1 ka-table-title">邮 箱</div>
                                <div id="ka_account" class="layui-col-xs10 ka-table-value1" style="width: calc(100% - 180px);">` + userInfor.user.email + `</div>
                                <div class="layui-col-xs1" style="width: 50px;margin-top: 5px;margin-right: 5px;height: 36px;line-height: 45px;text-align: center;font-size: 12px;">
                                    <a href="javascript:void(0);" onclick="kaOtherEvent.updateUserEmail('` + userInfor.user.id + `','` + userInfor.user.email + `');"><i class="layui-icon layui-icon-edit" style="font-size: 12px;font-weight: 900;"></i> 修改</a>
                                </div>
                            </div>
                        `
                        + `</div>`
                        + `<div class="layui-col-xs12">`
                        + `<fieldset class="layui-elem-field">
                            <legend>岗位</legend>
                            <div class="layui-field-box">
                                ` + postsHtml + `
                            </div>
                        </fieldset>
                        <fieldset class="layui-elem-field">
                            <legend>角色</legend>
                            <div class="layui-field-box">
                                ` + rolesHtml + `
                            </div>
                        </fieldset>
                        <fieldset class="layui-elem-field">
                            <legend>公司</legend>
                            <div class="layui-field-box">
                                ` + tenantHtml + `
                            </div>
                        </fieldset>
                     `
                        + `</div>`
                        ;
                }
            }
            bodyHtml = bodyHtml + `</div>`;
            return bodyHtml;
        },
        type13: function (body, divId) {
            var bodyHtml = `<div class="layui-btn-container">`;
            for (var j in body) {
                bodyHtml = bodyHtml
                    + `<button  style="font-size: 12px;margin-right: 2px;" type="button" class="layui-btn layui-btn-sm layui-btn-primary">`
                    + `<i style="font-size: 11px;" class="` + body[j].icon + `"></i> <span>` + (body[j].title != undefined && body[j].title != null && body[j].title != "" ? body[j].title : (body[j].name != undefined && body[j].name != null && body[j].name != "") ? body[j].name : body[j].menuName) + `</span><span style="margin-left: 15px;color: #a9a9a9;">( ` + body[j].clickCount + ` )</span>`
                    + `</button>`;
                var tbArray = kaHtml.type13ButtonMap.get(divId);
                if (tbArray == undefined || tbArray == null || tbArray.length == 0) {
                    tbArray = [];
                }
                tbArray.push(body[j]);
                if (kaHtml.type13ButtonMap != undefined && kaHtml.type13ButtonMap != null) {
                    kaHtml.type13ButtonMap.set(divId, tbArray);
                } else {
                    kaHtml.type13ButtonMap = new Map();
                    kaHtml.type13ButtonMap.set(divId, tbArray);
                }
            }
            bodyHtml = bodyHtml + `</div>`;
            return bodyHtml;
        }
    }
}
//加载Html内容的事件
var kaHtmlLoadEvent = {
    delete: function (divId) { //初始化删除原来的缓存
        kaHtml.dropdownMap.delete(divId);
        kaHtml.type2ButtonMap.delete(divId);
        kaHtml.type3ButtonMap.delete(divId);
        kaHtml.type4ButtonMap.delete(divId);
        kaHtml.type5ButtonMap.delete(divId);
        kaHtml.type6ButtonMap.delete(divId);
        kaHtml.type7ButtonMap.delete(divId);
        kaHtml.type8ButtonMap.delete(divId);
        kaHtml.type9ButtonMap.delete(divId);
        kaHtml.type10ButtonMap.delete(divId);
    },
    head: {//加载头部内容
        top: function (divId) {
            var dmArray = kaHtml.dropdownMap.get(divId);
            if (dmArray != undefined && dmArray != null && dmArray.length > 0) {
                for (var i in dmArray) {
                    var dm = dmArray[i];
                    // 自定义事件
                    layui.dropdown.render({
                        elem: '#' + dm.id,
                        data: dm.mbs,
                        click: function (obj) {
                            for (var j in dm.mbs) {
                                var mbs = dm.mbs[j];
                                if (mbs.id == obj.id) {
                                    mbs.cb();
                                    break;
                                }
                            }
                        }
                    });
                }
            }
        }
    },
    body: {//加载类型2 分割按钮
        type2: function (divId) {
            var tbArray = kaHtml.type2ButtonMap.get(divId);
            if (tbArray != undefined && tbArray != null && tbArray.length > 0) {
                for (var i in tbArray) {
                    var tb = tbArray[i];
                    $("#" + tb.id).click(function () {
                        var that = this;
                        tb.cb(that);
                    });
                }
            }
        },
        type3: function (divId) {
            var bodyId = kaHtml.type3ButtonMap.get(divId);
            //工作状态
            //加载所有工作状态
            kaOtherEvent.getWorkStatusList(bodyId);
            //获取工作状态
            kaOtherEvent.workingStatus(bodyId);
            //签到 判断更新状态
            kaOtherEvent.verifySigninHtml(bodyId);
            //签到
            $("#" + bodyId + "_qd").click(function () {
                kaOtherEvent.verifySignin(bodyId, function (newbodyId, re) {
                    var vs = re.verifySignin;
                    if (!vs) {
                        kaOtherEvent.signin(newbodyId);
                    }
                });

            });
            // 获取当前是星期几
            var date = new Date();
            var dayOfWeek = date.getDay();
            var weekHtml = `星期` + (dayOfWeek == 0 ? "日" : dayOfWeek == 1 ? "一" : dayOfWeek == 2 ? "二" : dayOfWeek == 3 ? "三" : dayOfWeek == 4 ? "四" : dayOfWeek == 5 ? "五" : "六");
            $("#" + bodyId + "_week").html(weekHtml);
            //签到次数
            kaOtherEvent.getSigninNumber(bodyId);
            //时钟
            if (bodyId != undefined && bodyId != null && bodyId != "") {
                $('#' + bodyId + "_sz").timeTo();
            }
        },
        type4: function (divId) {
            var body = kaHtml.type4ButtonMap.get(divId);
            if (body != undefined && body != null && body != "") {
                kagrid.loading(body);
            }
        },
        type5: function (divId) {
            var tbArray = kaHtml.type5ButtonMap.get(divId);
            if (tbArray != undefined && tbArray != null && tbArray.length > 0) {
                for (var i in tbArray) {
                    var tb = tbArray[i];
                    $("#menuType5" + tb.id).click(function () {
                        var that = this;
                        tb.cb(that);
                    });
                }
            }
        },
        type6: function (divId) {
            var body = kaHtml.type6ButtonMap.get(divId);
            layui.tabs.render();
            if (body != undefined && body != null && body != "") {
                $(".ka-new-tab").find(".layui-tabs-item").each(function () {
                    $(this).find(".layui-colla-title").each(function (index) {
                        $(this).append(`<span style="position: absolute;left: 7px;top: 11px;font-size: 14px;float: left;background: var(--global-primary-color);color: #fff;height: 12px;line-height: 12px;padding: 5px;padding-left: 6px;padding-right: 6px;border-radius: 3px;">` + (index + 1) + `</span>`);
                    })
                });
            }
            //加载广告
            var option = kaValue.getUrl("getNcad");
            option.success = function (re) {
                if (re.code == 200) {
                    var ncadDivHtml = ``;
                    var data = re.data;
                    if (data.length > 0) {
                        for (var i in data) {
                            ncadDivHtml = data[i].synopsis;
                            $("#ncadDivMain" + data[i].newtype).show();
                            break;
                        }
                        $("#ncadDiv" + data[i].newtype).html(ncadDivHtml);
                    }
                }
            }
            ka.ajax(option);
        },
        type7: function (divId) {

        },
        type8: function (divId) {
            var body = kaHtml.type8ButtonMap.get(divId);
            if (body != undefined && body != null && body != "") {
                setTimeout(function () {
                    $("#" + body.id + "_scrollbox").meuiTextScroll({
                        source: { "data": body.data }, //数据源
                        format: ["name", "synopsis", "createTime", "sort"],
                        // caption: body.title,
                        line: 1,
                        speed: 5000,
                        timer: 100,
                        direction: 'up',
                        pageBtn: false
                    });
                }, 200);

            }
        },
        type9: function (divId) {

        },
        type10: function (divId) {

        }
    }
}
var kaOtherEvent = {
    getWorkStatusList: function (bodyId) {//获取工作状态 /system/dict/data
        var option = kaValue.getUrl("getDicDataByType");
        option.url = option.url + "/sys_work_status";
        option.success = function (re) {
            if (re.code == 200) {
                var redata = re.data;
                var rds = [];
                for (var j in redata) {
                    var rd = {};
                    rd["title"] = redata[j].dictLabel
                    rd["id"] = redata[j].dictCode + "_ws_code"
                    rds.push(rd);
                }
                layui.dropdown.render({
                    elem: '#' + bodyId + "_gzzt_select", // 绑定元素选择器，此处指向 class 可同时绑定多个元素
                    data: rds,
                    click: function (obj) {
                        kaOtherEvent.updateWorkStatus(obj.title, function () {
                            kaOtherEvent.workingStatus(bodyId);
                        });
                    }
                });
            }
        }
        ka.ajax(option);
    },
    getUserInfor: function () {
        var userInfor = {};
        var option = kaValue.getUrl("getInfo");
        option.async = false;
        option.success = function (re) {
            if (re.code == 200) {
                userInfor = re;
            }
        }
        ka.ajax(option);
        return userInfor;
    },
    updateWorkStatus: function (title, callback) {//更新工作状态
        var option = kaValue.getUrl("updateWorkStatus");
        option.data = {
            "ws": title
        }
        option.success = function (re) {
            if (re.code == 200) {
                if (callback != undefined && callback != null && callback != "") {
                    callback(re);
                }
            }
        }
        ka.ajax(option);
    },
    workingStatus: function (bodyId, callback) {//获取工作状态
        var option = kaValue.getUrl("getWorkStatus");
        option.success = function (re) {
            if (re.code == 200) {
                $("#" + bodyId + "_gzzt").html('' + re.WorkStatus);
                if (callback != undefined && callback != null && callback != "") {
                    callback(re);
                }
            }
        }
        ka.ajax(option);
    },
    signin: function (bodyId, callback) {//签到
        var option = kaValue.getUrl("signin");
        option.success = function (re) {
            if (re.code == 200) {
                kaMsg.success(re);
                kaOtherEvent.verifySigninHtml(bodyId);
                if (callback != undefined && callback != null && callback != "") {
                    callback(bodyId, re);
                }
            } else {
                kaMsg.error(re);
            }
        }
        ka.ajax(option);
    },
    verifySignin: function (bodyId, callback) {
        var option = kaValue.getUrl("verifySignin");
        option.success = function (re) {
            if (re.code == 200) {
                if (callback != undefined && callback != null && callback != "") {
                    callback(bodyId, re);
                }
            } else {
                kaMsg.error(re);
            }
        }
        ka.ajax(option);
    },
    verifySigninHtml: function (bodyId) {//验证当天是否验证
        kaOtherEvent.verifySignin(bodyId, function (newbodyId, re) {
            var vs = re.verifySignin;
            if (vs) {
                $("#" + newbodyId + "_qd").css("filter", "drop-shadow(0px 1px 1px #0066ff)");
                $("#" + newbodyId + "_qd").css("background", "unset");
                $("#" + newbodyId + "_qd").css("background-color", "unset !important");
                $("#" + newbodyId + "_qd").css("padding", "0px");
                $("#" + newbodyId + "_qd").css("border", "1px dashed");
                $("#" + newbodyId + "_qd").html(`<img src="static/images/qdcg.png" style="width: 100%;"/>`);
                kaOtherEvent.getSigninNumber(bodyId);
            }
        });
    },
    getSigninNumber: function (bodyId, callback) {//获取签到次数
        var option = kaValue.getUrl("getSigninNumber");
        option.success = function (re) {
            if (re.code == 200) {
                $("#" + bodyId + "_qd_day").html(re.number);
                if (callback != undefined && callback != null && callback != "") {
                    callback(re);
                }
            } else {
                kaMsg.error(re);
            }
        }
        ka.ajax(option);
    },
    lookSigninList: function (bodyId) {//查看签到列表
        var gridBody = {
            id: "lookSigninGrid",
            fsv: {},
            fv: [],//查询条件
            column: [
                { headerName: '签到日期', field: 'signInTime', kaSort: true },
                { headerName: '签到IP地址', field: 'ipaddr', kaSort: true },
                { headerName: '签到地点', field: 'loginLocation', kaSort: true },
                { headerName: '签到浏览器类型', field: 'browser', kaSort: true },
                { headerName: '签到操作系统', field: 'os', kaSort: true }
            ]
        };
        var gridDivHtml = kagrid.getHtml(gridBody);
        layer.open({
            type: 1,
            shadeClose: true,
            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
            area: ['58%', '60%'],
            title: false,
            dataType: 4,
            content: `<div style="width: 99%;height: 100%;margin: 0 auto;">` + gridDivHtml + `</div>`,
            success: function () {
                kagrid.loading(gridBody);
            }
        });
    },
    edit: function () {

    },
    userBannerEdit: function (uuid) {//用户Banner编辑
        var myopt = {
            title: "用户Banner编辑",
            synopsis: "请上传一个1615 × 200 px 的Banner图",
            accept: "image/*",
            size: 1000,
            mb: {
                title: "",
                url: ""
            },
            cb: function (res) {
                var option = kaValue.getUrl("UserBannerEdit");
                option.data = {
                    "banners": res.fileName
                }
                option.success = function (re) {
                    if (re.code == 200) {
                        $("#" + uuid).attr("src", kaValue.ctx() + res.fileName);
                    }
                }
                ka.ajax(option);
            }
        };
        kafile.open(myopt);
    },
    userAvatarEdit: function (uuid) {//用户Banner编辑
        var myopt = {
            title: "用户Avatar编辑",
            synopsis: "请上传一个300 × 300 px 的Avatar图",
            accept: "image/*",
            size: 1000,
            mb: {
                title: "",
                url: ""
            },
            cb: function (res) {
                var option = kaValue.getUrl("UserAvatarEdit");
                option.data = {
                    "avatar": res.fileName
                }
                option.success = function (re) {
                    if (re.code == 200) {
                        $("#" + uuid).attr("src", kaValue.ctx() + res.fileName);
                    }
                }
                ka.ajax(option);
            }
        };
        kafile.open(myopt);
    },
    updateUserMobilePhone: function (uuid, phonenumber) {//用户手机号编辑
        var uuid = ka.uuidStr();
        layui.layer.open({
            type: 1, // page 层类型
            area: ['537px', '313px'],
            title: '<i class="icon iconfont icon-phone" style="margin-top: 10px;text-align: center;width: 50px;height: 50px;line-height: 50px;font-size: 30px;float: left;position: absolute;background-color: #f3f1ff;border-radius: 50%;"></i>',
            offset: ['20%', '30%'],
            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
            maxmin: false, // 允许全屏最小化
            anim: 0, // 0-6 的动画形式，-1 不开启
            content: `
            <script>
                var updateUserMobilePhoneSliderVerifyBoolean = false;
            </script>
            <div style="padding-left: 15px;padding-right: 15px;">
                <div style="font-size: 17px;font-weight: bold;margin-bottom: 5px;margin-top: 25px;line-height: 1.6;">手机号码更新</div>
                <div style="color: #989898;margin-top: 5px;font-size: 12px;line-height: 1.6;">中国使用的号码为11位，其中各段有不同的编码方向：第1-3位—网络识别号；第4-7位—地区编码；第8-11位—用户号码。</div>
                <form class="layui-form layui-form-pane" action="" style="display: block;margin-top: 25px;">
                    <div class="layui-form-item">
						<label class="layui-form-label">原手机号码:</label>
						<div class="layui-input-block">
							<input type="text" id="phonenumber` + uuid + `" name="phonenumber" value="` + phonenumber + `" placeholder="请输入手机号码" autocomplete="off" class="layui-input">
						</div>
					</div>
                    <div class="layui-form-item" style="margin-bottom: 0px;">
						<div class="layui-form-item">
							<label class="layui-form-label">手机验证码:</label>
							<div class="layui-input-inline" style="width: 381px;">
								<div class="layui-row">
									<div class="layui-col-xs9">
										<div class="layui-input-wrap">
											<div class="layui-input-prefix">
												<i class="layui-icon layui-icon-auz"></i>
											</div>
											<input id="codePhonenumber` + uuid + `" name="codePhonenumber" lay-vertype="tips" placeholder="手机验证码" type="text" autocomplete="off" lay-affix="clear" class="layui-input">
										</div>
									</div>
									<div class="layui-col-xs3">
										<div style="margin-left: 11px;">
											<button type="button" id="PhonenVerCodeButton" onclick="kaOtherEvent.getUpdateUserMobilePhoneVerCode('phonenumber` + uuid + `')" style="background: unset;color: var(--global-primary-color)!important;" class="layui-btn layui-btn-fluid layui-btn-primary layui-border-blue">获取</button>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
                </form>
                <div>
                    <a class="layui-btn layui-btn-sm" uurid="` + uuid + `" id="updateUserMobilePhone_btn" style="position: absolute;bottom: 10px;right: 12px;">确定修改</a>
                </div>
            </div>
            `,
            success: function () {
                $("#updateUserMobilePhone_btn").click(function () {
                    var uurid = $(this).attr("uurid");
                    var phonenumber = $("#phonenumber" + uurid).val();
                    var codePhonenumber = $("#codePhonenumber" + uurid).val();
                    if (phonenumber == undefined || phonenumber == null || phonenumber == "") {
                        kaMsg.error({ "code": "500", "msg": "手机号码不能为空！" });
                        return false;
                    }
                    if (!(/^1\d{10}$/.test(phonenumber))) {
                        kaMsg.error({ "code": "500", "msg": "手机号码不正确！" });
                        return false;
                    }
                    if (codePhonenumber == undefined || codePhonenumber == null || codePhonenumber == "") {
                        kaMsg.error({ "code": "500", "msg": "手机号码编码不能为空！" });
                        return false;
                    }
                    var option = kaValue.getUrl("updateUserMobilePhone");
                    option.data = {
                        "phonenumber": phonenumber,
                        "codePhonenumber": codePhonenumber,
                        "uuid": uuid
                    }
                    option.success = function (re) {
                        if (re.code == 200) {
                            top.window.location.reload();
                        } else {
                            kaMsg.error({ "code": re.code, "msg": re.msg });
                        }
                    }
                    ka.ajax(option);
                })
            }
        });
    },
    updateUserEmail: function (uuid, email) {//用户邮箱编辑
        var uuid = ka.uuidStr();
        layui.layer.open({
            type: 1, // page 层类型
            area: ['537px', '313px'],
            title: '<i class="icon iconfont icon-mail" style="margin-top: 10px;text-align: center;width: 50px;height: 50px;line-height: 50px;font-size: 30px;float: left;position: absolute;background-color: #f3f1ff;border-radius: 50%;"></i>',
            offset: ['20%', '30%'],
            shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
            maxmin: false, // 允许全屏最小化
            anim: 0, // 0-6 的动画形式，-1 不开启
            content: `
            <div style="padding-left: 15px;padding-right: 15px;">
                <div style="font-size: 17px;font-weight: bold;margin-bottom: 5px;margin-top: 25px;line-height: 1.6;">邮箱更新</div>
                <div style="color: #989898;margin-top: 5px;font-size: 12px;line-height: 1.6;">电子邮箱格式通常为“用户名@域名”，例如“username@example.com”。 邮件服务商不限制用户名中包含的字符，但特殊字符的使用可能不被所有服务商支持。</div>
                <form class="layui-form layui-form-pane" action="" style="display: block;margin-top: 25px;">
                    <div class="layui-form-item">
						<label class="layui-form-label">邮箱:</label>
						<div class="layui-input-block">
							<input type="text" id="email` + uuid + `" name="email" value="` + email + `" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
						</div>
					</div>
                </form>
                <div>
                    <a class="layui-btn layui-btn-sm" uurid="` + uuid + `" id="updateUserEmail_btn" style="position: absolute;bottom: 10px;right: 12px;">确定修改</a>
                </div>
            </div>
            `,
            success: function () {
                $("#updateUserEmail_btn").click(function () {
                    var uurid = $(this).attr("uurid");
                    var email = $("#email" + uurid).val();
                    if (email == undefined || email == null || email == "") {
                        kaMsg.error({ "code": "500", "msg": "邮箱不能为空！" });
                        return false;
                    }
                    var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                    if (!(regex.test(email))) {
                        kaMsg.error({ "code": "500", "msg": "邮箱不正确！" });
                        return false;
                    }
                    var option = kaValue.getUrl("updateUserEmail");
                    option.data = {
                        "email": email,
                        "uuid": uuid
                    }
                    option.success = function (re) {
                        if (re.code == 200) {
                            top.window.location.reload();
                        } else {
                            kaMsg.error({ "code": re.code, "msg": re.msg });
                        }
                    }
                    ka.ajax(option);
                })
            }
        });
    },
    getUpdateUserMobilePhoneVerCode: function (phonenumberuuid) {//获取手机验证码
        var phonenumber = $("#" + phonenumberuuid).val();
        if (phonenumber != undefined && phonenumber != null && phonenumber != "") {
            var regMobile = kaValue.regMobile;
            if (!regMobile.test(phonenumber)) {
                var option = {
                    code: "500",
                    msg: "请输入正确的手机号!"
                }
                kaMsg.error(option);
                return false;
            }
        } else {
            var option = {
                code: "500",
                msg: "请填写手机号码!"
            }
            kaMsg.error(option);
            return false;
        }
        kaOtherEvent.getUpdateUserMobilePhoneVerCodeSliderVerify();
        if (updateUserMobilePhoneSliderVerifyBoolean) {
            updateUserMobilePhoneSliderVerifyBoolean = false;
            kaOtherEvent.UpdateUserMobilePhoneVerCodePhonenVerCodeButtonFun(1);
            var tenant = $("#tenant").val();
            var option = kaValue.getUrl("getPhonenVerCode");
            option.data = {
                "phonenumber": phonenumber,
                "type": 3,
                "tenant": tenant
            };
            option.success = function (re) {
                if (re.code == 200) {
                    kaMsg.success(re);
                } else {
                    kaMsg.error(re);
                }
            }
            ka.ajax(option);
        }
    },
    UpdateUserMobilePhoneVerCodePhonenVerCodeButtonFun: function (types) {// 获取验证按钮
        if (types == 1) {
            var PhonenVerCodeButtonNumberStr = sessionStorage.getItem("PhonenVerCodeButtonNumber");
            if (PhonenVerCodeButtonNumberStr == undefined || PhonenVerCodeButtonNumberStr == null || PhonenVerCodeButtonNumberStr == "") {
                PhonenVerCodeButtonNumberStr = "60";
            }
            var PhonenVerCodeButtonNumber = parseInt(PhonenVerCodeButtonNumberStr);
            if (PhonenVerCodeButtonNumber > 0) {
                $("#PhonenVerCodeButton").html(PhonenVerCodeButtonNumber);
                $("#PhonenVerCodeButton").addClass("layui-btn-disabled");
                $("#PhonenVerCodeButton").prop('disabled', true); // 禁用按钮
                setTimeout(function () {
                    sessionStorage.setItem("PhonenVerCodeButtonNumber", (PhonenVerCodeButtonNumber - 1));
                    kaOtherEvent.UpdateUserMobilePhoneVerCodePhonenVerCodeButtonFun(1);
                }, 1000);
            } else {
                $("#PhonenVerCodeButton").html("获取");
                $("#PhonenVerCodeButton").removeClass("layui-btn-disabled");
                $("#PhonenVerCodeButton").removeAttr('disabled');
                sessionStorage.removeItem("PhonenVerCodeButtonNumber");
            }
        } else {
            var PhonenVerCodeButtonNumberStr = sessionStorage.getItem("PhonenVerCodeButtonNumber");
            if (!(PhonenVerCodeButtonNumberStr == undefined || PhonenVerCodeButtonNumberStr == null || PhonenVerCodeButtonNumberStr == "")) {
                var PhonenVerCodeButtonNumber = parseInt(PhonenVerCodeButtonNumberStr);
                if (PhonenVerCodeButtonNumber > 0) {
                    $("#PhonenVerCodeButton").html(PhonenVerCodeButtonNumber);
                    $("#PhonenVerCodeButton").addClass("layui-btn-disabled");
                    $("#PhonenVerCodeButton").prop('disabled', true); // 禁用按钮
                    setTimeout(function () {
                        sessionStorage.setItem("PhonenVerCodeButtonNumber", (PhonenVerCodeButtonNumber - 1));
                        kaOtherEvent.UpdateUserMobilePhoneVerCodePhonenVerCodeButtonFun(1);
                    }, 1000);
                }
            }
        }
    },
    getUpdateUserMobilePhoneVerCodeSliderVerify: function () { // 打开点击验证码
        if (!updateUserMobilePhoneSliderVerifyBoolean) {
            var commonAdGetSliderVerify = [];
            var option = kaValue.getUrl("commonAdGetSliderVerify");
            option.async = false;
            option.success = function (re) {
                if (re.code == 200) {
                    commonAdGetSliderVerify = re.data;
                }
            }
            ka.ajax(option);
            var layerIndex = layer.open({
                type: 1,
                area: ['304px', '376px'], // 宽高
                title: false, // 不显示标题栏
                closeBtn: 0,
                shade: [0.6, '#FFF'], // 点击遮罩区域，关闭弹层
                shadeClose: false, // 点击遮罩关闭层
                content: `<div id="sliderVerify"></div>`,
                success: function (layero, index, that) {
                    $('#sliderVerify').pointsVerify({
                        defaultNum: 5, //默认的文字数量
                        checkNum: 4, //校对的文字数量
                        vSpace: 4, //间隔
                        imgName: commonAdGetSliderVerify,
                        imgSize: {
                            width: '280px',
                            height: '290px',
                        },
                        barSize: {
                            width: '90%',
                            height: '40px',
                        },
                        ready: function () { },
                        success: function () {
                            updateUserMobilePhoneSliderVerifyBoolean = true;
                            layui.layer.closeAll();
                            kaOtherEvent.getUpdateUserMobilePhoneVerCode();
                        },
                        error: function () {
                            updateUserMobilePhoneSliderVerifyBoolean = false;
                            kalog.outLogs(["sliderVerify生成错误", {}]);
                        }
                    });
                    $(".verify-close").click(function () {
                        layui.layer.close(layerIndex);
                    });
                }
            });
        }
    }
}